// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const { ipcRenderer } = require('electron');
const { BrowserWindow } = require('electron').remote;

window.addEventListener('DOMContentLoaded', () => {
    // 使用 node 变量
    document.getElementById('node-version').innerHTML = process.version;
    document.getElementById('send').addEventListener('click', () => {
        // 参数 发送事件的名称, 发送的信息
        ipcRenderer.send('message', 'hello from renderer');
        let win = new BrowserWindow({
            width: 800,
            height: 600
        });
        win.loadURL('https://baidu.com').then(r => {});
    });
    ipcRenderer.on('reply', (event, args) => {
        document.getElementById('message').innerHTML = args;
    })
});
